package com.bilibili.juc.base;

import java.util.concurrent.*;

/**
 * @author zuife
 * @description
 * @since 2024-04-20 13:33:51
 */
public class CompletableFutureBuildDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService threadPool = Executors.newFixedThreadPool(3);
        CompletableFuture<Void> voidCompletableFuture = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName() + "runAsync");
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, threadPool);
        System.out.println(voidCompletableFuture.get());
        threadPool.shutdown();
    }

}
